package com.lzh.shijicloudstack.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzh.shijicloudstack.mapper.UnitMapper;
import com.lzh.shijicloudstack.model.dto.unit.AddUnitDto;
import com.lzh.shijicloudstack.model.dto.unit.EditUnitDto;
import com.lzh.shijicloudstack.model.entity.Unit;
import com.lzh.shijicloudstack.service.UnitService;
import org.springframework.stereotype.Service;

/**
 * @author luzhiheng
 * @date 2025-01-25
 */
@Service
public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements UnitService {

    @Override
    public Boolean add(AddUnitDto dto) {
        Unit unit = new Unit();
        unit.setName(dto.getName());
        return baseMapper.insert(unit) > 0;
    }

    @Override
    public Boolean edit(EditUnitDto dto) {
        Unit unit = new Unit();
        unit.setId(dto.getId());
        unit.setName(dto.getName());
        return baseMapper.updateById(unit) > 0;
    }
}
